/**
 * Copyright 2012 Pablo Danilo Aliscioni
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */

package ar.com.pabloaliscioni.cloud.api;

import java.util.Set;

/**
 * Interface defining all methods available for any storage provider.
 * 
 * @author Pablo Danilo Aliscioni
 * @since 1.0
 */
public interface IStorageClient
{
	/**
	 * Gets the name of the storage provider.
	 * 
	 * @return The name of the storage provider
	 */
	String getProviderName();
	
	/**
	 * Checks if a container exists
	 * 
	 * @param containerName Name of the container to check
	 * @return True if the container exists or false if it doesn't
	 */
	boolean containerExists(String containerName);
	
	/**
	 * Creates a new container.
	 * 
	 * @param containerName Name of the container to be created
	 */
	void createContainer(String containerName);
	
	/**
	 * Deletes a container
	 * 
	 * @param containerName Name of the container to be deleted
	 */
	void deleteContainer(String containerName);
	
	/**
	 * Deletes a file
	 * 
	 * @param containerName Name of the container where the file is stored
	 * @param fileName Name of the file
	 */
	void deleteFile(String containerName, String fileName);
	
	/**
	 * Checks if a file exists
	 * 
	 * @param containerName Name of the container where the file is stored
	 * @param fileName Name of the file
	 * @return True if the file exists or false if it doesn't
	 */
	boolean fileExists(String containerName, String fileName);
	
	/**
	 * Gets the content of the given file
	 * 
	 * @param containerName Name of the container where the file is stored
	 * @param fileName Name of the file
	 * @return The content of the file
	 */
	byte[] getFileContent(String containerName, String fileName);
	
	/**
	 * Gets the content type of the given file
	 * 
	 * @param containerName Name of the container where the file is stored
	 * @param fileName Name of the file
	 * @return The content type of the file
	 */
	String getFileContentType(String containerName, String fileName);
	
	/**
	 * Lists the name of the containers in the storage account
	 * 
	 * @return A Set of strings representing the containers in the storage account
	 */
	Set<String> listContainers();
	
	/**
	 * Lists the name of the files stored in a given container
	 * 
	 * @param containerName Name of the container
	 * @return A Set of strings representing the files stored within the given container
	 */
	Set<String> listFiles(String containerName);
	
	/**
	 * Saves a file to the given container
	 * 
	 * @param containerName Name of the container where the file is stored
	 * @param fileName Name of the file
	 * @param fileContent Content of the file
	 */
	void saveFile(String containerName, String fileName, byte[] fileContent);
	
	/**
	 * Saves a file to the given container
	 * 
	 * @param containerName Name of the container where the file is stored
	 * @param fileName Name of the file
	 * @param fileContent Content of the file
	 * @param contentType Content type for the file
	 */
	void saveFile(String containerName, String fileName, byte[] fileContent, String contentType);
}
